package com.apache.poi.word.config.policy;

import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.policy.RenderPolicy;
import com.deepoove.poi.template.ElementTemplate;
import com.deepoove.poi.template.run.RunTemplate;
import org.apache.poi.xwpf.usermodel.XWPFRun;

/**
 * @Author: HUANG GY.
 * @Date: 2022/2/10 15:48
 * @Description: com.apache.poi.word.config.policy
 */
public class HelloWorldRenderPolicy implements RenderPolicy {

    @Override
    public void render(ElementTemplate eleTemplate, Object data, XWPFTemplate template) {
        //获取当前位置
        XWPFRun run = ((RunTemplate) eleTemplate).getRun();
        // String thing = String.valueOf(data);
        //把当前位置的文本设置为hello world
        String thing = "Hello, world";
        run.setText(thing, 0);
    }

}
